ToolResult

@Serializable
@SerialName(value = "tool-result")
data class ToolResult(val toolCallId: String, val toolName: String, val output: JsonElement, val isError: Boolean = false, val modelVisible: JsonElement = output, val dynamic: Boolean = false, val providerExecuted: Boolean = false, val providerMetadata: Map<String, JsonElement>? = null) : ContentPart

Tool execution result. output is the canonical FULL payload — persisted, dispatched to UI converters, rendered as the rich card. modelVisible is what the LLM provider includes in the prompt on subsequent turns — defaults to output, but tools with a toModelOutput callback (see Tool.toModelOutput) supply a short summary so multi-turn conversations don't keep re-feeding 10k+ tokens of structured payload into the model's KV cache. The two are intentionally separate: rehydrating the UI card needs the full schema; the model only needs enough context to compose a follow-up response.

Constructors

Link copied to clipboard
constructor(toolCallId: String, toolName: String, output: JsonElement, isError: Boolean = false, modelVisible: JsonElement = output, dynamic: Boolean = false, providerExecuted: Boolean = false, providerMetadata: Map<String, JsonElement>? = null)

Properties

Link copied to clipboard

Result of a dynamic (runtime-typed) tool call. v6 parity.

Link copied to clipboard
Link copied to clipboard
val ContentPart.metadata: Map<String, JsonElement>?
Link copied to clipboard
val modelVisible: JsonElement
Link copied to clipboard
val output: JsonElement
Link copied to clipboard

Tool was executed by the provider. v6 parity.

Link copied to clipboard
val providerMetadata: Map<String, JsonElement>?
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
inline fun <T> ContentPart.providerMetadataAs(provider: String): T?
fun <T> ContentPart.providerMetadataAs(provider: String, serializer: KSerializer<T>): T?